{% extends "base.html" %}
{% block header %}
<script type="text/javascript" src="/static/js/jquery.treeview.js"></script>
<script type="text/javascript" src="/static/js/jquery.cookie.js"></script>
<script type="text/javascript">
	function startMonitor(){
		$.get("/monitor/monitorstatus/", {'do':'start'},function(data){
			  alert("Data Loaded: " + data);
			});
	}

	function stopMonitor(){
		$.get("/monitor/monitorstatus/", {'do':'stop'},function(data){
			  alert("Data Loaded: " + data);
			});
	}

	function initBind1(){
		$('#stop').bind('click', function (){ stopMonitor()});
	}

	function initBind2(){
		$('#start').bind('click', function (){ startMonitor()});
	}

	$(document).ready(function(){
		//$("#browser").html("<li><span class='folder'>test1</span></li>");
		initBind1();
		initBind2();
		$(".tabs > ul").tabs();
	    $("#browser").treeview({
            persist: "cookie",
			toggle: function() {
				console.log("%s was toggled.", $(this).find(">span").text());
			}
		});
	});
	$(document).ready(function(){
		$("#f").hide();
		$("#search").click(function(){
			$("#f").show();
		});
		$("#shouqi").click(function(){
			$("#f").hide();
		});
	});
</script>

{% endblock %}
{% block menu %}
   {% include 'accident-menu.html' %}
{% endblock %}

{% block content %}
        <div id="mon-tit">
            <div class="left">暴风事故中心 >> 事故列表</div>
            <div class="right"><a href="/accident/addac/">添加事故记录</a></div>
        </div>
        <div class="clr"></div>
        <hr>
        <h3 class='tit'>事故列表<span> <a align="right" class="blue btn" id="search">打开搜索</a></span></h3>
        <div id="f">
			<form method="post" action="/accident/search/">
				简介：<input type="text" name="description" size="5">&nbsp;
				产品线：
					<select name="acpid" >
						<option value ="">-不限-</option>
						{% for l in plist %}
						<option value = "{{l.id}}">{{ l.name }}</option>
						{% endfor %}
					</select>&nbsp;
				等级：
				<select name="alevel" >
				<option value ="">-不限-</option>]
				<option value ="普通">-普通-</option>]
				<option value ="一级故障">-一级故障-</option>]
				<option value ="二级故障">-二级故障-</option>]
				<option value ="三级故障">-三级故障-</option>]
				</select>&nbsp;
				类型：
				<select name="atype" >
				<option value ="">-不限-</option>
				<option value ="人为">-人为-</option>
				<option value ="网络">-网络-</option>
				<option value ="硬件">-硬件-</option>
				<option value ="产品策略">-产品策略-</option>
				</select>&nbsp;
				<input type="submit" value="查询">&nbsp;
				<input type="button" value="收起" id="shouqi">
			</form>
        </div>
            {% if flag == "open" %}
				<a href="/monitor/export">导出搜索结果到CSV</a>
			{% endif %}
        <div id="mon-dis" class="right-col">
            <div class="title">
				<span style="width:25%">事故简介</span>
				<span style="width:25%">事故时间</span>
				<span style="width:9%">事故等级</span>
				<span style="width:9%">事故类型</span>
				<span style="width:18%">产品线</span>
				<span style="width:14%">操作</span>
            </div>
            
	{% if messages %}
		{% for message in messages %}
			{% if message == "modifysuccess" %}
				<script language=javascript>alert('修改监控信息成功!!');window.location.href='/monitor';</script>
			{% endif %}
			{% if message == "null" %}
				<h3>查询失败或无结果</h3>
			{% endif %}
			{% if message == "addsuccess" %}
				添加成功！
			{% endif %}
			{% if message == "ms" %}
				 <span style=color:#FF5151;>修改成功！</span>
			{% endif %}
		{% endfor %}
	{% endif %}
		{% for l in alst %}
			<div class="{% cycle 'ji' 'ou' %}" >
                <span style="width:25%">{{ l.description }}</span>
                <span style="width:25%">{{ l.abegintime }}</span>
                <span style="width:9%">{{ l.alevel }}</span>
                <span style="width:9%">{{ l.atype }}</span>
                <span style="width:18%">{{ l.acpid }}</span>
                <span style="width:14%">
                <a href="/accident/info/{{ l.id }}"> 详情 </a>|
                <a href="/accident/modify?id={{ l.id }}"> 修改 </a>|
                <a href="/accident/del/{{ l.id }}" onclick="if(confirm('确定删除监控么？')){}else{return false;};"> 删除</a></span>
            </div>
		{% endfor %}
        </div>
{% endblock %}
